﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Smartmanufact
{
    public partial class ADD_cargon_info : Form
    {
        public ADD_cargon_info()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // 判断各个变量
            if (textBox_id.Text.Trim() == "") { MessageBox.Show("货物种类ID不能为空！");return; }
            if (textBox_name.Text.Trim() == "") { MessageBox.Show("货物名称不能为空！"); return; }
            try 
            {
                string id = textBox_id.Text.Trim();
                string name = textBox_name.Text.Trim();
                string note = richTextBox_note.Text.Trim();
                bool right= MainView.mysql.excute_sql("insert into cargoinfotable values('"+id+"','"+name+"','"+note+"')");
                if(right==false)
                {
                    MessageBox.Show("填加过程出现错误！");
                    return;
                }
                this.Dispose();
            }
            catch { MessageBox.Show("添加过程中出现错误！"); }
        }

        private void richTextBox_note_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
